package ext.tianma.bom.service.test;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping({"/engineConfigDocController"})
public class EngineConfigurationDocController {
	
	private static final String CLASSNAME = EngineConfigurationDocController.class.getName();
	
	/**
	 * 获取发动机配置文档产品系列的所有下拉值
	 * 
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/queryProductSerial",method = { RequestMethod.POST, RequestMethod.GET })	
	public void productSerialCombobox(HttpServletResponse response) throws Exception{
	//	boolean enforce = wt.session.SessionServerHelper.manager.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("application/json; charset=UTF-8");
		JSONObject jo = new JSONObject();
		try {
			 jo.put("name", "gaoxf");
			 out.print(jo.toJSONString());
		//	out.print(EngineConfigurationDocNumberConfig.getEngineConfigurationDocNumberConfig());
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
	//		wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
	
	/**
	 * 根据发动机配置文档的产品系列的下拉值来获取其最新流水码
	 * 
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/productSerialSequence",method = { RequestMethod.POST, RequestMethod.GET })	
	public void productSerialSequence(@RequestParam(value = "productSerial",required=true) String productSerial,
			HttpServletResponse response) throws Exception{
		boolean enforce = wt.session.SessionServerHelper.manager.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");//返回文本值
		JSONObject jo = new JSONObject();
		try {
			//long maxNumber = EngineConfigurationDocNumberService.getMaxNumberByProductRules(productSerial);
			out.print("1111111111111111111111");
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
	
	/**
	 * 更新发动机配置文档产品系列的最大值
	 * 
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateMaxNumber",method = { RequestMethod.POST, RequestMethod.GET })	
	public void productSerialSequence(@RequestParam(value = "maxNumber",required=true) String maxNumber,
			@RequestParam(value = "rule",required=true) String rule,
			HttpServletResponse response) throws Exception{
		boolean enforce = wt.session.SessionServerHelper.manager.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("application/json; charset=UTF-8");
		try {
		//	String result = EngineConfigurationDocNumberService.updateMaxNumberByProductRules(rule, maxNumber);
			out.print("====maxNumbe:"+maxNumber+"==rule:"+rule);
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}
	
	
}
